#define _CRT_SECURE_NO_WARNINGS



#include<iostream>
using namespace std;
int main()
{
    int len;
    char ch;
    int cnt = 0;
    string s;
    cin >> len >> ch;
    cin >> s;
    for (int i = 0; i < len; i++)
    {
        if (s[i] == ch)
        {
            int l = i;
            int r = len - 1 - i;
            int k = min(l, r);
            cnt += k + 1;
        }
    }
    cout << cnt;
    return 0;
}

